package blog.modelo;

// Generated Oct 24, 2014 1:54:18 PM by Hibernate Tools 4.3.1

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 * BlogCategory generated by hbm2java
 */
@Entity
@Table(name = "blog_category", uniqueConstraints = @UniqueConstraint(columnNames = "name_clean"))
public class BlogCategory implements java.io.Serializable {

	private Integer id;
	private String name;
	private String nameClean;
	private boolean enabled;
	private Date dateCreated;
	private Set<BlogPost> blogPosts = new HashSet<BlogPost>(0);

	public BlogCategory() {
	}

	public BlogCategory(String name, boolean enabled) {
		this.name = name;
		this.enabled = enabled;
	}

	public BlogCategory(String name, String nameClean, boolean enabled,
			Date dateCreated, Set<BlogPost> blogPosts) {
		this.name = name;
		this.nameClean = nameClean;
		this.enabled = enabled;
		this.dateCreated = dateCreated;
		this.blogPosts = blogPosts;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name", nullable = false, length = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "name_clean", unique = true, length = 45)
	public String getNameClean() {
		return this.nameClean;
	}

	public void setNameClean(String nameClean) {
		this.nameClean = nameClean;
	}

	@Column(name = "enabled", nullable = false)
	public boolean isEnabled() {
		return this.enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date_created", length = 19)
	public Date getDateCreated() {
		return this.dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "blog_post_to_category",  joinColumns = { @JoinColumn(name = "category_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "post_id", nullable = false, updatable = false) })
	public Set<BlogPost> getBlogPosts() {
		return this.blogPosts;
	}

	public void setBlogPosts(Set<BlogPost> blogPosts) {
		this.blogPosts = blogPosts;
	}

}
